package com.ql.controller;

import com.ql.domain.response.JsonResult;
import com.ql.domain.Section;
import com.ql.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/section")
public class SectionController {
    @Autowired
    SectionService sectionService;

    @RequestMapping("/findAll.do")
    @ResponseBody
    public JsonResult findAll(String sectionName, @RequestParam(name = "page", required = true, defaultValue = "1") Integer page, @RequestParam(name = "limit", required = true, defaultValue = "10") Integer limit) {
        return sectionService.findAll(sectionName, page, limit);
    }

    @RequestMapping("/save.do")
    @ResponseBody
    public JsonResult save(Section section) {
        return sectionService.save(section);
    }

    @RequestMapping("/update.do")
    @ResponseBody
    public JsonResult update(Section section) {
        return sectionService.update(section);
    }

    @RequestMapping("/del.do")
    @ResponseBody
    public JsonResult del(String sectionId) {
        return sectionService.del(sectionId);
    }

    @RequestMapping("/sectionGroupNameByUserId.do")
    @ResponseBody
    public List<Section> sectionGroupNameByUserId(String userId) {
        return sectionService.sectionGroupName(userId);
    }
    @RequestMapping("/sectionGroupName.do")
    @ResponseBody
    public List<Section> sectionGroupName(String projectId,String userId) {
        return sectionService.sectionGroupNameByProjectId(projectId,userId);
    }
}
